#pragma once

#include<iostream>

#include "alglib\ap.h"
#include "alglib\linalg.h"
#include "alglib\alglibinternal.h"
#include "alglib\alglibmisc.h"

class LSIcompute{
public:
	LSIcompute(double * TFM, const int d, const int t, double * approxiError, int * pGroups, int * pPseudoTermNum);
	~LSIcompute();
	void runCompution();

private:
	int docNum;
	int termNum;
	double * pTFM;	//Term Frequency Matrix
	int * groups;
	int * psTermNum;
	double * approxiErrorMax;
	double ** pseudoTM;

	alglib::real_2d_array A;
	alglib::real_1d_array S;
	alglib::real_2d_array U;
	alglib::real_2d_array Vt;

	void ComputeSVD();
	void ComputeApproxiError();
	void InitializePseudoTM();
	void MatchToGroup();
};